home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
basic
/
iqb9103.zip
/
SCROLL.BAS
< prev
Wrap
BASIC Source File
|
1991-02-22
|
3KB
|
138 lines
' Program - SCROLL.BAS
' Demonstrates scrolling rectangular text areas using any
' standard video mode. Text can be scrolled up n lines,
' down n lines, or the area can be completely blanked.
'$INCLUDE: 'QB.BI'
TYPE Rectangle
X1 AS INTEGER
Y1 AS INTEGER
X2 AS INTEGER
Y2 AS INTEGER
END TYPE
DECLARE SUB Scroll (Rec AS Rectangle, Lines%, BlankColor%)
DECLARE SUB WaitKey ()
' This rectangle will contain upper left and lower right
' row and column text coordinates for scrolling.
DIM Rec AS Rectangle
' Let's get started.
CLS
PRINT "SCROLL.BAS"
PRINT
INPUT "Enter screen mode >", Vmode%
INPUT "Enter width (40 or 80) >", Vwidth%
INPUT "Enter blanking color >", BlankColor%
' Set minimum number of lines for the given screen mode.
IF Vmode% = 11 OR Vmode% = 12 THEN
Vlines% = 30
ELSE
Vlines% = 25
END IF
' Set the screen mode, width, and lines. The program will
' halt here if you select an illegal combination.
SCREEN Vmode%
WIDTH Vwidth%, Vlines%
' Display text lines for demonstrating the scrolling.
CLS
FOR I% = 1 TO 8
PRINT STRING$(35, 64 + I%)
PRINT STRING$(35, "-")
NEXT I%
LOCATE 25,50 : PRINT "Press any key to continue..."
WaitKey ' Wait for a keypress before 1st scroll
' Scroll up one line.
Rec.X1 = 5
Rec.Y1 = 4
Rec.X2 = 10
Rec.Y2 = 12
Scroll Rec, 1, BlankColor%
WaitKey
' Scroll down three lines.
Rec.X1 = 15
Rec.X2 = 20
Scroll Rec, -3, BlankColor%
WaitKey
' Blank the entire rectangular area.
Rec.X1 = 25
Rec.X2 = 30
Scroll Rec, 0, BlankColor%
WaitKey
' Finally, do "block-art" until any key is pressed. This
' demonstrates the speed of the scrolling on your system.
DO
' Pick a random rectangular area of the screen.
Rec.X1 = INT(RND * Vwidth% + 1)
Rec.Y1 = INT(RND * Vlines% + 1)
Rec.X2 = INT(RND * Vwidth% + 1)
Rec.Y2 = INT(RND * Vlines% + 1)
' Make sure rows and columns are in the right order.
IF Rec.X1 > Rec.X2 THEN SWAP Rec.X1, Rec.X2
IF Rec.Y1 > Rec.Y2 THEN SWAP Rec.Y1, Rec.Y2
' Select a random blanking color.
IF Vmode% <> 13 THEN
BlankColor% = INT(RND * 16)
ELSE
BlankColor% = INT(RND * 256)
END IF
' Scroll the rectangular region, blanking all lines.
Scroll Rec, 0, BlankColor%
LOOP WHILE INKEY$ = ""
END
SUB Scroll (Rec AS Rectangle, Lines%, BlankColor%)
DIM Regs AS RegType
' Get current video mode and character columns.
Regs.AX = &HF00
Interrupt &H10, Regs, Regs
VideoMode% = Regs.AX AND &HFF
' The blanking color attribute depends on the specific
' video mode and number of text columns.
IF Regs.AX = &H2801 OR Regs.AX = &H5003 THEN
Attribute% = CVI(MKL$(BlankColor% * 4096&))
ELSEIF VideoMode% = 4 OR VideoMode% = 6 THEN
Attribute% = 0
ELSE
Attribute% = CVI(MKL$(BlankColor% * 256&))
END IF
' Load the registers.
IF Lines% < 0 THEN
Regs.AX = &H700 OR (ABS(Lines%) AND &HFF)
ELSE
Regs.AX = &H600 OR (Lines% AND &HFF)
END IF
Regs.bx = Attribute%
Regs.cx = Rec.Y1 * 256 + Rec.X1 - 257
Regs.dx = Rec.Y2 * 256 + Rec.X2 - 257
' Call video scroll function.
Interrupt &H10, Regs, Regs
END SUB
' Prompt the user to press a key
SUB WaitKey STATIC
BEEP : DO WHILE INKEY$ = "" : LOOP
END SUB